package com.runfast.paotui.config;

import org.springframework.context.annotation.Configuration;

/**
 * @author: lijin
 * @date: 2018年04月26日
 */
public class Schedule {

     /*@Bean
    @Qualifier("jobDetailFactoryBean")
    JobDetailFactoryBean JobDetailFactoryBean() {
        JobDetailFactoryBean jobDetailFactoryBean = new JobDetailFactoryBean();
        jobDetailFactoryBean.setJobClass(CancelOrderJob.class);
        jobDetailFactoryBean.setDurability(true);
        return jobDetailFactoryBean;
    }

    @Bean
    CronTriggerFactoryBean CronTriggerFactoryBean() {
        CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
        cronTriggerFactoryBean.setJobDetail(JobDetailFactoryBean().getObject());
        cronTriggerFactoryBean.setCronExpression("0 * * * * ? *");
        return cronTriggerFactoryBean;
    }

    @Bean
    SimpleTriggerFactoryBean SimpleTriggerFactoryBean(@Qualifier("methodInvokingJobDetailFactoryBean") JobDetail jobDetail) {

        SimpleTriggerFactoryBean simpleTriggerFactoryBean = new SimpleTriggerFactoryBean();
        simpleTriggerFactoryBean.setJobDetail(jobDetail);
        simpleTriggerFactoryBean.setStartDelay(1000);
        simpleTriggerFactoryBean.setRepeatInterval(600000);
        return simpleTriggerFactoryBean;

    }

    @Bean
    @Qualifier("methodInvokingJobDetailFactoryBean")
    MethodInvokingJobDetailFactoryBean MethodInvokingJobDetailFactoryBean(ExampleBusinessObject object) {
        MethodInvokingJobDetailFactoryBean methodInvokingJobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
        methodInvokingJobDetailFactoryBean.setTargetObject(object);
        methodInvokingJobDetailFactoryBean.setTargetMethod("doIt");
        methodInvokingJobDetailFactoryBean.setConcurrent(false);
        return methodInvokingJobDetailFactoryBean;
    }*/

    /*@Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/doc/index.html");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }*/
}
